home *** CD-ROM | disk | FTP | other *** search
/ Hardcore Visual Basic 5.0 (2nd Edition) / Hardcore Visual Basic 5.0 - Second Edition (1997)(Microsoft Press).iso / Code / LOCALM~1 / WinIter.bas < prev    next >
BASIC Source File  |  1997-06-14  |  2KB  |  54 lines

  1. Attribute VB_Name = "MWinIter"
  2. Option Explicit
  3.  
  4. Public Enum EErrorWinIter
  5.     eeBaseWinIter = 13630   ' WinIter
  6. End Enum
  7.  
  8. Function IterateChildWindows(ByVal iLevel As Integer, _
  9.                              ByVal hWnd As Long, _
  10.                              helper As IWindowsHelper) As Long
  11.     BugAssert hWnd <> hNull
  12.  
  13.     ' Handle current window, allowing user to fail
  14.     
  15.     IterateChildWindows = helper.DoWindow(iLevel, hWnd)
  16.     If IterateChildWindows <> hNull Then Exit Function
  17.     ' Get its child (if any)
  18.     hWnd = GetWindow(hWnd, GW_CHILD)
  19.     ' Iterate through each child window
  20.     Do While hWnd <> hNull
  21.         IterateChildWindows = _
  22.             IterateChildWindows(iLevel + 1, hWnd, helper)
  23.         If IterateChildWindows <> hNull Then Exit Function
  24.         ' Get next child
  25.         hWnd = GetWindow(hWnd, GW_HWNDNEXT)
  26.         ' Give other processes some cycles
  27.         DoEvents
  28.     Loop
  29.     ' Nothing found
  30.     IterateChildWindows = hNull
  31.  
  32. End Function
  33.  
  34. #If fComponent = 0 Then
  35. Private Sub ErrRaise(e As Long)
  36.     Dim sText As String, sSource As String
  37.     If e > 1000 Then
  38.         sSource = App.ExeName & ".WinIter"
  39.         Select Case e
  40.         Case eeBaseWinIter
  41.             BugAssert True
  42.        ' Case ee...
  43.        '     Add additional errors
  44.         End Select
  45.         Err.Raise COMError(e), sSource, sText
  46.     Else
  47.         ' Raise standard Visual Basic error
  48.         sSource = App.ExeName & ".VBError"
  49.         Err.Raise e, sSource
  50.     End If
  51. End Sub
  52. #End If
  53.  
  54.